<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // 字面量创建对象
        var wangDaDan = {
            name: '王大胆',
            age: 18,
            stature: '190cm',
            sex: '男',
            skin: '白色',
            oSing: function () {
                console.log('歌颂中。。。')
            },
            oCode: function () {
                console.log('打代码');
            },
            eat: function () {
                console.log('会吃饭');
            },
            drive: function () {
                console.log('会开车');
            }
        }
        // 系统构造函数创建对象
        var wangDaDan = new Object();
        wangDaDan.name = '王大胆';
        wangDaDan.age = 18;
        wangDaDan.stature = '190cm';
        wangDaDan.sex = '男';
        wangDaDan.skin = '白色';
        wangDaDan.oSing = function () {
                console.log('唱歌');
            };
            wangDaDan.oCode = function () {
                console.log('打代码');
            };
            wangDaDan.eat = function () {
                console.log('会吃饭');
            };
            wangDaDan.drive = function () {
                console.log('会开车');
            };
        // 自定义函数创建对象
        function Person(name,age,stature,sex,skin) {
            this.name = name;
            this.age = age;
            this.stature = stature;
            this.sex = sex;
            this.skin = skin;
            this.oSing = function () {
                console.log('唱歌');
            };
            this.oCode = function () {
                console.log('打代码');
            };
            this.eat = function () {
                console.log('会吃饭');
            };
            this.drive = function () {
                console.log('会开车');
            };
        }
        // 向构造函数的原型添加跳舞能力
        Person.prototype.dance = function () {
            console.log('dance');
        }
        var WangDaDan = new Person('王大胆',18,'190cm','男','白色');
        WangDaDan.drive();
        alert(wangDaDan['name']);
    </script>
</body>
</html>